<?php
/**
 * Author: 式神(vashi)
 * email: 289650682@qq.com
 * Date: 2019/04/11 10:12
 * FileName: Menu.php
 */

namespace app\cms\model;


class Menu extends Common
{
    protected $tip_name = '菜单';
    protected $validate;
    protected $table;

    public function initialize()
    {
        parent::initialize();
        $this->validate = new \app\cms\validate\Menu();
    }

    //添加规则
    public function add($input){
        if(!isset($input['status']) || !$input['status']){
            $input['status']=0;
        }
        if(!isset($input['pid']) || !$input['pid']){
            $input['pid']=0;
        }
        if(!isset($input['sort']) || !$input['sort']){
            $input['sort']=0;
        }
        if(!isset($input['link']) || !$input['link']){
            $input['link']="";
        }
        if($input['type'] == 1 && (!isset($input['link']) || !$input['link']) ){
            $input['link']=0;
        }
        return $this->addModel($input);
    }

    //编辑规则
    public function edit($input){
        if(!isset($input['status']) || !$input['status']){
            $input['status']=0;
        }
        if(!isset($input['pid']) || !$input['pid']){
            $input['pid']=0;
        }
        if(!isset($input['sort']) || !$input['sort']){
            $input['sort']=0;
        }
        if(!isset($input['link']) || !$input['link']){
            $input['link']="";
        }
        if($input['type'] == 1 && (!isset($input['link']) || !$input['link']) ){
            $input['link']=0;
        }
        return $this->editModel($input);
    }

    public function del($input){
        return $this->delModel($input);
    }
}